Ext.namespace('Taxamatch');

Taxamatch.BrowseAuthorities = function(config) {

	this.ds = new Ext.data.JsonStore({
			proxy: new Ext.data.HttpProxy({
					url: 'resources/api/app.php'
			})
		,	baseParams: { 
					cmd: 'browseAuthority'
			}
		,	root: 'data'
		,	totalProperty: 'totalCount'
		,	remoteSort: true
		,	fields:	[
					{name: 'family'}
				,	{name: 'genus'}
				,	{name: 'species'}	
			]
	});

	this.sm =	new Ext.grid.RowSelectionModel({
			singleSelect: true
	});

	Ext.apply(this, config, {
			width: 500
		,	height: 250
		,	layout: 'fit'
		,	modal: true
		,	resizable: false
		,	defaults: {
					border: false
				//,	xtype: 'button'
			}
		,	items: [{
				xtype: 'grid'
			,	ref: 'grid1'	
			,	store: this.ds	
			,	sm: this.sm
			,	loadMask: {msg: 'Loading...'}
			,	columns: [{
						xtype: 'gridcolumn'
					,	id: 'family'	
					,	dataIndex: 'family'
					,	header: 'Family'
					,	sortable: true
					,	width: 100
				},{
						xtype: 'gridcolumn'
					,	id: 'genus'	
					,	dataIndex: 'genus'
					,	header: 'Genus'
					,	sortable: true
					,	width: 100
				},{
						xtype: 'gridcolumn'
					,	id: 'species '	
					,	dataIndex: 'species'
					,	header: 'Species'
					,	sortable: true
					,	width: 100
				}]
			,	bbar: new Ext.PagingToolbar({
						pageSize: 50
					,	store: this.ds
					,	displayInfo: true
					,	displayMsg: 'Displaying name  {0} - {1} of {2}'
					,	emptyMsg: 'No names available.'
				})
			}]
	});
	
	Taxamatch.BrowseAuthorities.superclass.constructor.call(this, config);
	
};

Ext.extend(Taxamatch.BrowseAuthorities, Ext.Window, {
});